﻿using Cocon90.Lib.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace Demo
{
    public partial class Demo : Form
    {
        public Demo()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //System.Threading.Tasks.Task<int> task =
            //    new System.Threading.Tasks.Task<int>(new Func<int>(() => { System.Threading.Thread.Sleep(2000); return 10; }));

            //System.Threading.Tasks.Task<int> task2 =
            //    new System.Threading.Tasks.Task<int>(new Func<int>(() => { System.Threading.Thread.Sleep(2000); return 20; }));

            //System.Threading.Tasks.Task<int> task3 =
            //    new System.Threading.Tasks.Task<int>(new Func<int>(() => { System.Threading.Thread.Sleep(2000); return 30; }));

            //int result = 0;

            //Cocon90.Lib.Util.ThreadInvoker.CreateInstence().Invoke(() =>
            //{

            //    result = System.Threading.Tasks.Task.Factory.StartNew(() =>
            //    {
            //        task.Start();
            //        MessageBox.Show(task.Result + "");
            //    }).ContinueWith<int>((tk) => { tk.Dispose(); task2.Start(); task3.Start(); return task2.Result + task3.Result; }).Result;


            //}, (lst) =>
            //{
            //    MessageBox.Show("线程结果：" + result);
            //});

            //int sum = 0;
            //const int count = 200;
            //Logger log = new Logger("c://log//");
            //for (int i = 0; i < count; i++)
            //{
            //    System.Threading.Tasks.Task.Factory.StartNew(() =>
            //    {
            //        sum++;
            //        log.addToLog(String.Format("time:{0}|ms:{1}|i:{2}|sum:{3}", DateTime.Now.ToLongTimeString(), DateTime.Now.Millisecond, i,sum));
            //    });
            //}

            sqlHelperDemo sd = new sqlHelperDemo();
            sd.Show();

        }

        private void button2_Click(object sender, EventArgs e)
        {
            BaseStoreDemo bsd = new BaseStoreDemo();
            bsd.Show();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            EditableStoreDemo esd = new EditableStoreDemo();
            esd.Show();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            ModelHelperDemo mdh = new ModelHelperDemo();
            mdh.Show();
        }

        private void button6_Click(object sender, EventArgs e)
        {
            SearchStoreDemo ssd = new SearchStoreDemo();
            ssd.Show();
        }

        private void button7_Click(object sender, EventArgs e)
        {
            Util.InIDemo ini = new Util.InIDemo();
            ini.Show();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            Util.Logger log = new Util.Logger();
            log.Show();
        }

        private void button9_Click(object sender, EventArgs e)
        {
            Util.ThreadInvokerDemo iid = new Util.ThreadInvokerDemo();
            iid.Show();
        }

        private void button10_Click(object sender, EventArgs e)
        {
            Util.DelayInvokerDemo di = new Util.DelayInvokerDemo();
            di.Show();
        }

        private void button11_Click(object sender, EventArgs e)
        {
            Util.IntervalInvokerDemo iid = new Util.IntervalInvokerDemo();
            iid.Show();
        }

        private void button12_Click(object sender, EventArgs e)
        {
            Util.KeyboardApiDemo ki = new Util.KeyboardApiDemo();
            ki.Show();
        }

        private void button13_Click(object sender, EventArgs e)
        {
            Util.MouseApiDemo ma = new Util.MouseApiDemo();
            ma.Show();
        }
    }
}
